package tag;

import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.*;
import java.io.*;

public class CattrTag extends SimpleTagSupport {

    private String message;

    private boolean isok;

    /**
     * setter方法用于设置属性
     * @param msg
     */
    public void setMessage(String msg) {
        this.message = msg;
    }

    /**
     * 设置属性类型
     * @param isok
     */
    public void setIsok(boolean isok) {
        this.isok = isok;
    }

    StringWriter sw = new StringWriter();

    public void doTag() throws JspException, IOException {
        if (message != null) {
            /* Use message from attribute */
            JspWriter out = getJspContext().getOut();
            out.println( message );
        } else {
            /* use message from the body */
            getJspBody().invoke(sw);
            getJspContext().getOut().println(sw.toString());
        }
    }
}
